package com.ilab.view.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.ilab.R;
public class PicListViewAdapter extends BaseAdapter{
	private ArrayList<Integer> data;
    private LayoutInflater mInflater; 
    private int viewResource = -1;
	public PicListViewAdapter(Context context,int viewResource,ArrayList<Integer> data) {  
		this.mInflater = LayoutInflater.from(context);  
	    this.data = data;
	    this.viewResource = viewResource;
	}  

    @Override  
    public int getCount() {  
        return data.size();  
    }  

    @Override  
    public Object getItem(int position) {  
    	return data.get(position);  
    }  

    @Override  
    public long getItemId(int position) {  
        return position;  
    }  

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView pic = null;  
        if (convertView == null) {  
            convertView = mInflater.inflate(viewResource, null);
            pic = (ImageView) convertView.findViewById(R.id.pic);  
            convertView.setTag(pic);  
        } else {  
        	pic = (ImageView) convertView.getTag();  
        }
        pic.setImageResource(data.get(position));
        return convertView;  
	}

}
